using UnityEngine;
using System.Collections;
namespace COC.Test{
public class Welcome : MonoBehaviour
{
		public UISlider progressbar;
		public UILabel progressbar_info;
		public UITexture backgroundGUITexture;
		bool isFinished;

		void OnGUI ()
		{

				//resize background image size to fit screen.
				//backgroundGUITexture.pixelInset.width = Screen.currentResolution.width;
		//backgroundGUITexture.pixelInset = new Rect ( 0.5f,0.5f, Screen.width, Screen.height);
		//backgroundGUITexture.transform.localScale=new Vector3(Screen.currentResolution.width,Screen.currentResolution.height,0);
		//GUI.DrawTexture(new Rect (0.5f, 0.5f, Screen.currentResolution.width, Screen.currentResolution.height), backgroundGUITexture);
	}

		void Awake ()
		{
		//backgroundGUITexture.shader=(Resources.Load("Scenes/TranslucentShader",typeof(Shader)) as Shader);
				if (progressbar == null && progressbar_info == null) {
						GameObject go = GameObject.FindGameObjectWithTag ("Login_progressbar");
						GameObject gOProgressInfo = GameObject.FindGameObjectWithTag ("Login_progressbar_info");
						UISlider slider;
						UILabel _info;
						if (go != null && gOProgressInfo != null) {
								{
										slider = go.GetComponent<UISlider> ();
										_info = gOProgressInfo.GetComponent<UILabel> ();
								}
								if (slider != null) {
										progressbar = slider;
								}
								if (_info != null)
										progressbar_info = _info;
						}
				}
		}
		// Use this for initialization
		void Start ()
		{
				InvokeRepeating ("Loading", 2, 3f);
		}
	
		void Loading ()
		{
				UnityEngine.Debug.Log ("progressbar.value = " + progressbar.value);
		        
				progressbar.value += 0.2f;
				
		}
		// Update is called once per frame
		void Update ()
		{
				if (progressbar.value >= 1) {
						CancelInvoke ("Loading");
						Application.LoadLevel ("COCDemo");
				}
		}
}

}